//////////////////////////////////////////
// Make Table S9
//////////////////////////////////////////

version 15

gl path "~/Dropbox/CovidTurnout/replication"

use "$path/original_data/analysis_file.dta", clear
keep if inlist(age, 64, 65)

* Replace dem = 0 if missing
replace dem = 0 if dem==.

* Turnout
reg dem age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100, r
local b1 = _b[age65_2012]
local se1 = _se[age65_2012]
local n1 = e(N)
local ba1 = _b[age65_2020]
local sea1 = _se[age65_2020]
local bi1 = _b[is2020]
local sei1 = _se[is2020]
local ba181 = _b[age65_2018]
local sea181 = _se[age65_2018]
local bi181 = _b[is2018]
local sei181 = _se[is2018]
local ba161 = _b[age65_2016]
local sea161 = _se[age65_2016]
local bi161 = _b[is2016]
local sei161 = _se[is2016]
local ba141 = _b[age65_2014]
local sea141 = _se[age65_2014]
local bi141 = _b[is2014]
local sei141 = _se[is2014]
local c1 = _b[_cons]

* Absentee 
reg absentee age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==100, r
local b3 = _b[age65_2012]
local se3 = _se[age65_2012]
local n3 = e(N)
local ba3 = _b[age65_2020]
local sea3 = _se[age65_2020]
local bi3 = _b[is2020]
local sei3 = _se[is2020]
local ba183 = _b[age65_2018]
local sea183 = _se[age65_2018]
local bi183 = _b[is2018]
local sei183 = _se[is2018]
local ba163 = _b[age65_2016]
local sea163 = _se[age65_2016]
local bi163 = _b[is2016]
local sei163 = _se[is2016]
local ba143 = _b[age65_2014]
local sea143 = _se[age65_2014]
local bi143 = _b[is2014]
local sei143 = _se[is2014]
local c3 = _b[_cons]

reg absentee age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==0, r
local b4 = _b[age65_2012]
local se4 = _se[age65_2012]
local n4 = e(N)
local ba4 = _b[age65_2020]
local sea4 = _se[age65_2020]
local bi4 = _b[is2020]
local sei4 = _se[is2020]
local ba184 = _b[age65_2018]
local sea184 = _se[age65_2018]
local bi184 = _b[is2018]
local sei184 = _se[is2018]
local ba164 = _b[age65_2016]
local sea164 = _se[age65_2016]
local bi164 = _b[is2016]
local sei164 = _se[is2016]
local ba144 = _b[age65_2014]
local sea144 = _se[age65_2014]
local bi144 = _b[is2014]
local sei144 = _se[is2014]
local c4 = _b[_cons]


* Early Voting
reg early age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==100, r
local b5 = _b[age65_2012]
local se5 = _se[age65_2012]
local n5 = e(N)
local ba5 = _b[age65_2020]
local sea5 = _se[age65_2020]
local bi5 = _b[is2020]
local sei5 = _se[is2020]
local ba185 = _b[age65_2018]
local sea185 = _se[age65_2018]
local bi185 = _b[is2018]
local sei185 = _se[is2018]
local ba165 = _b[age65_2016]
local sea165 = _se[age65_2016]
local bi165 = _b[is2016]
local sei165 = _se[is2016]
local ba145 = _b[age65_2014]
local sea145 = _se[age65_2014]
local bi145 = _b[is2014]
local sei145 = _se[is2014]
local c5 = _b[_cons]

reg early age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==0, r
local b6 = _b[age65_2012]
local se6 = _se[age65_2012]
local n6 = e(N)
local ba6 = _b[age65_2020]
local sea6 = _se[age65_2020]
local bi6 = _b[is2020]
local sei6 = _se[is2020]
local ba186 = _b[age65_2018]
local sea186 = _se[age65_2018]
local bi186 = _b[is2018]
local sei186 = _se[is2018]
local ba166 = _b[age65_2016]
local sea166 = _se[age65_2016]
local bi166 = _b[is2016]
local sei166 = _se[is2016]
local ba146 = _b[age65_2014]
local sea146 = _se[age65_2014]
local bi146 = _b[is2014]
local sei146 = _se[is2014]
local c6 = _b[_cons]

* Election Day
reg precinct age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==100, r
local b7 = _b[age65_2012]
local se7 = _se[age65_2012]
local n7 = e(N)
local ba7 = _b[age65_2020]
local sea7 = _se[age65_2020]
local bi7 = _b[is2020]
local sei7 = _se[is2020]
local ba187 = _b[age65_2018]
local sea187 = _se[age65_2018]
local bi187 = _b[is2018]
local sei187 = _se[is2018]
local ba167 = _b[age65_2016]
local sea167 = _se[age65_2016]
local bi167 = _b[is2016]
local sei167 = _se[is2016]
local ba147 = _b[age65_2014]
local sea147 = _se[age65_2014]
local bi147 = _b[is2014]
local sei147 = _se[is2014]
local c7 = _b[_cons]

reg precinct age65_2020 is2020 age65_2018 is2018 age65_2016 is2016 age65_2014 is2014 age65_2012 [fw=obs] if voted==100 & dem==0, r
local b8 = _b[age65_2012]
local se8 = _se[age65_2012]
local n8 = e(N)
local ba8 = _b[age65_2020]
local sea8 = _se[age65_2020]
local bi8 = _b[is2020]
local sei8 = _se[is2020]
local ba188 = _b[age65_2018]
local sea188 = _se[age65_2018]
local bi188 = _b[is2018]
local sei188 = _se[is2018]
local ba168 = _b[age65_2016]
local sea168 = _se[age65_2016]
local bi168 = _b[is2016]
local sei168 = _se[is2016]
local ba148 = _b[age65_2014]
local sea148 = _se[age65_2014]
local bi148 = _b[is2014]
local sei148 = _se[is2014]
local c8 = _b[_cons]

quietly {
	cap log close
	set linesize 255

	log using "$path/output/party_table.tex", text replace
	
	noisily dis "\begin{table}[t]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Effect of No-Excuse Absentee Voting on Party Turnout, Texas General Elections, 2012-2020.}\label{tab:party}}"
	noisily dis "\resizebox{1\textwidth}{!}{"
	noisily dis "\begin{tabular}{lccccccc}"
	noisily dis "\toprule \toprule"
	noisily dis " & \shortstack{Dem \%\\ of Turnout} & \multicolumn{2}{c}{\shortstack{Absentee \%\\ of Turnout}} & \multicolumn{2}{c}{\shortstack{Early \%\\ of Turnout}} & \multicolumn{2}{c}{\shortstack{Elec. Day Ballots \%\\ of Turnout}} \\[2mm]"
	noisily dis " & & D & R & D & R & D & R \\[2mm]"
	noisily dis " & (1) & (2) & (3) & (4) & (5) & (6) & (7) \\"
	noisily dis "\midrule"
	noisily dis " \textbf{No-Excuse (Age=65)} $\mathbf{\times}$ \textbf{2020} & \textbf{" %5.2f `ba1' "} & \textbf{" %5.2f `ba3' "} & \textbf{" %5.2f `ba4' "} & \textbf{" %5.2f `ba5' "} & \textbf{" %5.2f `ba6' "} & \textbf{" %5.2f `ba7' "} & \textbf{" %5.2f `ba8' "} \\"
	noisily dis " & \textbf{(" %3.2f `sea1' ")} & \textbf{(" %3.2f `sea3' ")} & \textbf{(" %3.2f `sea4' ")} & \textbf{(" %3.2f `sea5' ")} & \textbf{(" %3.2f `sea6' ")} & \textbf{(" %3.2f `sea7' ")} & \textbf{(" %3.2f `sea8' ")} \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2018 & " %5.2f `ba181' "  & " %5.2f `ba183' " & " %5.2f `ba184' " & " %5.2f `ba185' " & " %5.2f `ba186' "  & " %5.2f `ba187' " & " %5.2f `ba188' " \\"
	noisily dis " & (" %3.2f `sea181' ")  & (" %3.2f `sea183' ") & (" %3.2f `sea184' ")  & (" %3.2f `sea185' ") & (" %3.2f `sea186' ") & (" %3.2f `sea187' ") & (" %3.2f `sea188' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2016 & " %5.2f `ba161' "  & " %5.2f `ba163' " & " %5.2f `ba164' " & " %5.2f `ba165' " & " %5.2f `ba166' "  & " %5.2f `ba167' " & " %5.2f `ba168' " \\"
	noisily dis " & (" %3.2f `sea161' ") & (" %3.2f `sea163' ") & (" %3.2f `sea164' ")  & (" %3.2f `sea165' ") & (" %3.2f `sea166' ") & (" %3.2f `sea167' ") & (" %3.2f `sea168' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2014 & " %5.2f `ba141' "  & " %5.2f `ba143' " & " %5.2f `ba144' " & " %5.2f `ba145' " & " %5.2f `ba146' "  & " %5.2f `ba147' " & " %5.2f `ba148' " \\"
	noisily dis " & (" %3.2f `sea141' ") & (" %3.2f `sea143' ") & (" %3.2f `sea144' ")  & (" %3.2f `sea145' ") & (" %3.2f `sea146' ") & (" %3.2f `sea147' ") & (" %3.2f `sea148' ") \\[2mm]"
	noisily dis "No-Excuse (Age=65) $\times$ 2012 & " %5.2fc `b1' " & " %5.2fc `b3' " & " %5.2fc `b4' "  & " %5.2fc `b5' " & " %5.2fc `b6' " & " %5.2fc `b7' " & " %5.2fc `b8' " \\"
	noisily dis " & (" %3.2f `se1' ") & (" %3.2f `se3' ") & (" %3.2f `se4' ") & (" %3.2f `se5' ") & (" %3.2f `se6' ") & (" %3.2f `se7' ") & (" %3.2f `se8' ") \\[2mm]"
	noisily dis "2020 & " %5.2f `bi1' " & " %5.2f `bi3' " & " %5.2f `bi4'  " & " %5.2f `bi5' " & " %5.2f `bi6' " & " %5.2f `bi7' " & " %5.2f `bi8' " \\"
	noisily dis " & (" %3.2f `sei1' ") & (" %3.2f `sei3' ") & (" %3.2f `sei4' ") & (" %3.2f `sei5' ") & (" %3.2f `sei6' ") & (" %3.2f `sei7' ") & (" %3.2f `sei8' ") \\[2mm]"
	noisily dis "2018 & " %5.2f `bi181' " & " %5.2f `bi183' " & " %5.2f `bi184' " & " %5.2f `bi185' " & " %5.2f `bi186' " & " %5.2f `bi187' " & " %5.2f `bi188' " \\"
	noisily dis " & (" %3.2f `sei181' ") & (" %3.2f `sei183' ") & (" %3.2f `sei184' ") & (" %3.2f `sei185' ") & (" %3.2f `sei186' ") & (" %3.2f `sei187' ") & (" %3.2f `sei188' ") \\[2mm]"
	noisily dis "2016 & " %5.2f `bi161' " & " %5.2f `bi163' " & " %5.2f `bi164' " & " %5.2f `bi165' " & " %5.2f `bi166' " & " %5.2f `bi167' " & " %5.2f `bi168' " \\"
	noisily dis " & (" %3.2f `sei161' ") & (" %3.2f `sei163' ") & (" %3.2f `sei164' ") & (" %3.2f `sei165' ") & (" %3.2f `sei166' ") & (" %3.2f `sei167' ") & (" %3.2f `sei168' ") \\[2mm]"
	noisily dis "2014 & " %5.2f `bi141' " & " %5.2f `bi143' " & " %5.2f `bi144' " & " %5.2f `bi145' " & " %5.2f `bi146' " & " %5.2f `bi147' " & " %5.2f `bi148' " \\"
	noisily dis " & (" %3.2f `sei141' ") & (" %3.2f `sei143' ") & (" %3.2f `sei144' ") & (" %3.2f `sei145' ") & (" %3.2f `sei146' ") & (" %3.2f `sei147' ") & (" %3.2f `sei148' ") \\[2mm]"
	noisily dis "Intercept (2012 mean) & " %5.2f `c1' " & " %5.2f `c3' " & " %5.2f `c4' " & " %5.2f `c5' " & " %5.2f `c6' " & " %5.2f `c7' " & " %5.2f `c8' " \\[2mm]"
	noisily dis " \# Obs & " %12.0fc `n1' " & " %12.0fc `n3' " & " %12.0fc `n4' " & " %12.0fc `n5' " & " %12.0fc `n6' " & " %12.0fc `n7' " & " %12.0fc `n8' " \\"
	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{8}{p{1.15\textwidth}}{\footnotesize Robust standard errors in parentheses. "
	noisily dis "Unit of observation is an individual by year. Texans aged 64 or younger who are eligible to vote"
	noisily dis " must provide a valid excuse if they wish to vote absentee. Those aged 65 or older who are eligible to vote can vote absentee without an excuse.}"
	noisily dis "\end{tabular}}"
	noisily dis "\end{table}"
	
	log off

}







